﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using FC.Model;


namespace FC.ViewModel.QuestionVMs
{
    public partial class QuestionListVM : BasePagedListVM<Question_View, QuestionSearcher>
    {

        protected override IEnumerable<IGridColumn<Question_View>> InitGridHeader()
        {
            return new List<GridColumn<Question_View>>{
                this.MakeGridHeader(x => x.Content),
                this.MakeGridHeader(x => x.Content_view),
                this.MakeGridHeaderAction(width: 200)
            };
        }

        public override IOrderedQueryable<Question_View> GetSearchQuery()
        {
            var query = DC.Set<Question>()
                .Select(x => new Question_View
                {
				    ID = x.ID,
                    Content = x.Content,
                    Content_view = x.Parent.Content,
                })
                .OrderBy(x => x.ID);
            return query;
        }

    }

    public class Question_View : Question{
        [Display(Name = "追问")]
        public String Content_view { get; set; }

    }
}
